# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=emacs-vterm
pkgver=0_git20240821
_gitrev=988279316fc89e6d78947b48513f248597ba969a
pkgrel=0
_pkgreal=vterm
pkgdesc="Fully-fledged terminal emulator based on libvterm"
url="https://github.com/akermu/emacs-libvterm"
arch="all"
license="GPL-3.0-or-later"
depends="cmd:emacs"
makedepends="
	cmake
	emacs-nox
	libvterm-dev
	ninja
	"
source="https://github.com/akermu/emacs-libvterm/archive/$_gitrev/emacs-vterm-$_gitrev.tar.gz"
builddir="$srcdir/emacs-libvterm-$_gitrev"
options="!check" # tests just run the terminal emulator for you to try out

prepare() {
	default_prepare

	# use system header file
	rm -v emacs-module.h
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_LIBVTERM=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build

	emacs -batch -q -no-site-file -L . \
		-f batch-byte-compile \
		./*.el
}

package() {
	install -Dvm644 ./*.el ./*.elc vterm-module.so \
		-t "$pkgdir"/usr/share/emacs/site-lisp/

	cd "$pkgdir"/usr/share/emacs/site-lisp
	emacs -batch -q -no-site-file \
		-eval "(loaddefs-generate \".\" \"$_pkgreal-loaddefs.el\")"
}

sha512sums="
aa78982e5c4c8958761791a6d3347f5d29fc164a520cc4639981070af1ed8e9a5702c259422daac01a709a9f3e9fbf05aab5553be677d89fa362cb678efad0db  emacs-vterm-988279316fc89e6d78947b48513f248597ba969a.tar.gz
"
